<?php

namespace app\model;

class AdminGoodsModel extends TimeModel{

    protected $table = "admin_goods";
    protected $schema = [
        'id' => 'int',  //id
        'image' => 'varchar',  //商品图片
        'recommend_image' => 'varchar',//推荐图
        'slider_image' => 'varchar',//轮播图
        'store_name' => 'varchar',//商品名称
        'store_info' => 'varchar',//商品简介
        'cate_id' => 'varchar',//分类id
        'price' => 'decimal',//商品价格 默认 0.00
        'vip_price' => 'decimal',//会员价格
        'ot_price' => 'decimal',//市场价
        'sales' => 'mediumint',//销量
        'stock' => 'mediumint',//库存
        'unit_name' => 'varchar',//单位名
        'is_show' => 'tinyint',//状态（0：未上架，1：上架）
        'cost' => 'decimal',//成本价
        'browse' => 'int',//浏览量
        'video_link' => 'varchar',//主图视频链接

        'create_time' => 'int',
        'update_time' => 'int',
        'delete_time' => 'int',
    ];

    /**
     * Author: yuShuangJiang
     * Time: 2021/6/27 9:57
     * @param $val
     * @return false|string
     */
    public function getCreateTimeAttr($val){
        return date('Y-m-d',$val);
    }
    public function getUpdateTimeAttr($val){
        return date('Y-m-d',$val);
    }
    public function getDeleteTimeAttr($val){
        return date('Y-m-d',$val);
    }
    public function setCreateTimeAttr($val){
        return strtotime($val);
    }
    public function setUpdateTimeAttr($val){
        return strtotime($val);
    }
    public function setDeleteTimeAttr($val){
        return strtotime($val);
    }
}